﻿<%@ Page Title="Adhoc Adjustments" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="AdhocAdjustment.aspx.cs" Inherits="TestJQGrid.AdhocAdjustment" %>

<%@ Register Assembly="Trirand.Web" Namespace="Trirand.Web.UI.WebControls" TagPrefix="Trirand" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <!-- The jQuery UI theme that will be used by the grid -->
    <link rel="stylesheet" type="text/css" media="screen" href="/themes/redmond/jquery-ui-1.8.2.custom.css" />
    <!-- The jQuery UI theme extension jqGrid needs -->
    <link rel="stylesheet" type="text/css" media="screen" href="/themes/ui.jqgrid.css" />
    <!-- jQuery runtime minified -->
    <script src="/js/jquery-1.4.4.min.js" type="text/javascript"></script>
    <!-- The localization file we need, English in this case -->
    <script src="/js/trirand/i18n/grid.locale-en.js" type="text/javascript"></script>
    <!-- The jqGrid client-side javascript -->
    <script src="/js/trirand/jquery.jqGrid.min.js" type="text/javascript"></script>
    <script src="/js/trirand/jquery.jqDatePicker.min.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table border="1" width="100%">
        <tr>
            <td align="center">
                <asp:Label ID="pageLable" runat="server" Text="Adhoc Adjustments" Font-Size="Medium"></asp:Label>
            </td>
        </tr>
        <tr>
            <td style="width: 100%;">
                <Trirand:JQGrid ID="JQGrid1" runat="server" DataSourceID="DSAdhoc" AutoWidth="true"
                    Height="300px">
                    <Columns>
                        <Trirand:JQGridColumn DataField="EntryID" PrimaryKey="True" Visible="false">
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="AgentID" Editable="true" EditType="DropDown" EditorControlID="DDAgents">
                            <EditClientSideValidators>
                                <Trirand:RequiredValidator />
                            </EditClientSideValidators>
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="Amount" Editable="true">
                            <EditClientSideValidators>
                                <Trirand:RequiredValidator />
                                <Trirand:NumberValidator />
                                <Trirand:MinValueValidator MinValue="0" />
                            </EditClientSideValidators>
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="Type" Editable="true" EditType="DropDown" EditorControlID="DDType">
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="PrePost" Editable="true" EditType="DropDown" EditorControlID="DDPrePost">
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="TaxCode" Editable="true" EditType="DropDown" EditorControlID="DDTaxes">
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="FromDate" DataFormatString="{0:dd/MM/yyyy}" Editable="true"
                            EditType="DatePicker" EditorControlID="JQDatePicker">
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="ToDate" DataFormatString="{0:dd/MM/yyyy}" Editable="true"
                            EditType="DatePicker" EditorControlID="JQDatePicker">
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="Remarks" Editable="true">
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="RAmount" Editable="true">
                            <EditClientSideValidators>
                                <Trirand:NumberValidator />
                                <Trirand:MinValueValidator MinValue="0" />
                            </EditClientSideValidators>
                        </Trirand:JQGridColumn>
                        <Trirand:JQGridColumn DataField="AdjType" Editable="true" EditType="DropDown" EditorControlID="DDAdjTypes">
                            <EditClientSideValidators>
                                <Trirand:RequiredValidator />
                            </EditClientSideValidators>
                        </Trirand:JQGridColumn>
                    </Columns>
                    <ToolBarSettings ShowAddButton="true" ShowEditButton="true" ShowDeleteButton="false"
                        ShowRefreshButton="True" ShowSearchButton="True" ShowViewRowDetailsButton="True" />
                    <EditDialogSettings CloseAfterEditing="True" />
                    <AddDialogSettings CloseAfterAdding="true" />
                    <SearchDialogSettings MultipleSearch="true" />
                    <AppearanceSettings ShrinkToFit="false" />
                    <SortSettings InitialSortColumn=""></SortSettings>
                </Trirand:JQGrid>
                <asp:DropDownList ID="DDTaxes" runat="server" DataTextField="Value" DataValueField="ColumnName">
                </asp:DropDownList>
                <asp:DropDownList ID="DDPrePost" runat="server">
                    <asp:ListItem Text="Pre" Value="Pre" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="Post" Value="Post"></asp:ListItem>
                </asp:DropDownList>
                <asp:DropDownList ID="DDType" runat="server">
                    <asp:ListItem Text="Credit" Value="Credit" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="Debit" Value="Debit"></asp:ListItem>
                </asp:DropDownList>
                <asp:DropDownList ID="DDAdjTypes" runat="server" DataSourceID="SDSAdjTypes" 
                    DataTextField="Value" DataValueField="Value">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SDSAdjTypes" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:AgentBillingConnectionString %>" 
                    SelectCommand="SELECT [Value] FROM [ValidValues] WHERE (([ColumnName] = @ColumnName2) AND ([TableName] = @TableName))">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="Adhoc" Name="ColumnName2" Type="String" />
                        <asp:Parameter DefaultValue="Adjustments" Name="TableName" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <asp:DropDownList ID="DDAgents" runat="server" DataTextField="AgentName" DataValueField="AgentId">
                </asp:DropDownList>
                <Trirand:JQDatePicker ID="JQDatePicker" runat="server" DateFormat="dd/MM/yyyy" ChangeMonth="true"
                    ChangeYear="true" DisplayMode="ControlEditor" />
                <asp:SqlDataSource ID="DSAdhoc" runat="server" ConnectionString="<%$ ConnectionStrings:AgentBillingConnectionString %>"
                    DeleteCommand="DELETE FROM [AdhocAdjustments] WHERE [EntryID] = @EntryID" InsertCommand="INSERT INTO [AdhocAdjustments] ([AgentID], [Amount], [Type], [PrePost], [TaxCode], [FromDate], [ToDate],[CreatedBy], [Remarks], [RAmount],[CreatedOn],[AdjType]) VALUES (@AgentID, @Amount, @Type, @PrePost, @TaxCode, @FromDate, @ToDate, @CreatedBy, @Remarks, @RAmount,getDate(),@AdjType)"
                    SelectCommand="SELECT * FROM [AdhocAdjustments]" UpdateCommand="UPDATE [AdhocAdjustments] SET [AgentID] = @AgentID, [Amount] = @Amount, [Type] = @Type, [PrePost] = @PrePost, [TaxCode] = @TaxCode, [FromDate] = @FromDate, [ToDate] = @ToDate,[AdjType] =@AdjType, [Remarks] = @Remarks, [RAmount] = @RAmount WHERE [EntryID] = @EntryID">
                    <DeleteParameters>
                        <asp:Parameter Name="EntryID" Type="Decimal" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="AgentID" Type="Decimal" />
                        <asp:Parameter Name="Amount" Type="Decimal" />
                        <asp:Parameter Name="Type" Type="String" />
                        <asp:Parameter Name="PrePost" Type="String" />
                        <asp:Parameter Name="TaxCode" Type="String" />
                        <asp:Parameter DbType="Date" Name="FromDate" />
                        <asp:Parameter DbType="Date" Name="ToDate" />
                        <asp:SessionParameter DefaultValue="'default'" Name="CreatedBy" Type="String" SessionField="loginId" />
                        <asp:Parameter Name="Remarks" Type="String" />
                        <asp:Parameter Name="RAmount" Type="Decimal" />
                        <asp:Parameter Name="AdjType" Type="String" DefaultValue="Penalty" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="AgentID" Type="Decimal" />
                        <asp:Parameter Name="Amount" Type="Decimal" />
                        <asp:Parameter Name="Type" Type="String" />
                        <asp:Parameter Name="PrePost" Type="String" />
                        <asp:Parameter Name="TaxCode" Type="String" />
                        <asp:Parameter DbType="Date" Name="FromDate" />
                        <asp:Parameter DbType="Date" Name="ToDate" />
                        <asp:Parameter Name="Remarks" Type="String" />
                        <asp:Parameter Name="RAmount" Type="Decimal" />
                        <asp:Parameter Name="EntryID" Type="Decimal" />
                        <asp:Parameter Name="AdjType" Type="String" DefaultValue="Penalty" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
</asp:Content>
